<<<<<<< HEAD
=======
const http = require('../../api/index')
const { baseURL } = require("../../utils/request")
>>>>>>> b386087e8fe490bfca457f942595dcfb7526435f
// index.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'

Page({
  data: {

    swiperList:[],// 存储轮播图的图片数组
    selectCampList:[],
    oss_url:baseURL,
    motto: 'Hello World',
    userInfo: {
      avatarUrl: defaultAvatarUrl,
      nickName: '',
    },
    hasUserInfo: false,
    canIUseGetUserProfile: wx.canIUse('getUserProfile'),
    canIUseNicknameComp: wx.canIUse('input.type.nickname'),

    indicatorDots: true,  
      autoplay: true,  
      interval: 3000,  
      duration: 500,  
      current: 0  
    },  


  bindViewTap() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onChooseAvatar(e) {
    const { avatarUrl } = e.detail
    const { nickName } = this.data.userInfo
    this.setData({
      "userInfo.avatarUrl": avatarUrl,
      hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
    })
  },
  onInputChange(e) {
    const nickName = e.detail.value
    const { avatarUrl } = this.data.userInfo
    this.setData({
      "userInfo.nickName": nickName,
      hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
    })
  },
  getUserProfile(e) {
    // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认，开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
    wx.getUserProfile({
      desc: '展示用户信息', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
      success: (res) => {
        console.log(res)
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    })
  },
  navigateToCampMap: function() {
    wx.navigateTo({
      url: '/pages/campMap/campMap'
    });
  },
  onLoad: function() {
    // this.fetchBannerList();
    this.setData({
      selectCampList:[{
        name:"campnameimg",
        imgUrl:"https://img95.699pic.com/photo/50114/9657.jpg_wh860.jpg"
      },
      {
        name:"campnameimg",
        imgUrl:"https://img.zcool.cn/community/011r230o16c7qtlkm0o3fm3635.jpg?x-oss-process=image/auto-orient,1/resize,m_lfit,w_1280,limit_1/sharpen,100"
      
      },
      {
        name:"campnameimg",
        imgUrl:"  https://www.xingkongmeng.com/Upload/20221018/6380169001281673041475513.jpg"

      }]
    })
  },
  godetail(){
    wx.navigateTo({//跳转页面
      url: '../detail/detail'
    })
  },
 bannerList() {
    http.getBannerList().then(res => {
      if (res.code === 200) {
        // let imageList = res.rows.filter(item => {
        //   return item.state == "1"
        // })
        this.setData({
          swiperList: res.rows
        });
      }
    });
  },
 infoList() {
    http.getBannerList().then(res => {
      if (res.code === 200) {
        // let imageList = res.rows.filter(item => {
        //   return item.state == "1"
        // })
        this.setData({
          swiperList: res.rows
        });
      }
    });
  },
  onShow() {
    console.log("getBannerList")
    this.bannerList();
    // http.getBannerList( (res) => {
    //   console.log("res", res); // 打印接收到的数据
    // })
  },
  swiperChange: function(e) {  
    this.setData({  
      current: e.detail.current  
    });  
  }  
})
